// 管理用户数据

import { defineStore } from 'pinia'
import { ref } from 'vue'

export const userStore = defineStore(
  'user',
  () => {
    const isDark = ref<boolean>(false)
    // 定义管理用户的数据state
    const userInfo = ref({
      studentId: '',
      stuName: '',
    })

    const defaultUrl = ref()
    // 清除用户数据
    const clearUserInfo = () => {
      userInfo.value = {
        studentId: '',
        stuName: '',
      }
      roleList.value=[]
      myMenuList.value=[]
    }
    const roleList=ref<string[]>([])
    const myMenuList=ref<any>([])
    // 以对象格式将state与action return
    return {
      roleList,
      myMenuList,
      userInfo,
      defaultUrl,
      clearUserInfo,
      isDark
    }
  },
  {
    persist: true
  }
)
